package com.ftg.supermarket.view;

import com.ftg.supermarket.comm.ToPage;
import com.ftg.supermarket.domain.UserDomain;
import com.ftg.supermarket.service.UserService;

import java.io.IOException;
import java.util.Scanner;

/**
 * 模拟注册功能
 *
 * @author 布衣
 */
public class UiRegister {

    /**
     * 动态sql语句
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {

        System.out.println("-=欢迎使用超市管理系统注册功能=-");

        Scanner s = new Scanner(System.in);

        System.out.println("请输入你的用户名");
        String username = s.next();

        System.out.println("请输入你的密码");
        String password = s.next();

        System.out.println("请输入你的确认密码");
        String password1 = s.next();

        if (password1.equals(password)) {
            UserService userService = new UserService();
            ToPage<Object> register = userService.register(username, password);
            if (register.getCode() == 200) {
                System.out.println(register.getMsg());
                System.out.println("去登陆页面了");
            } else {
                System.out.println("ToT");
                System.out.println(register.getMsg());
            }
        }


    }

}
